package com.tssup.fesco.common.config.common;

import java.util.Properties;

import tk.mybatis.spring.mapper.MapperScannerConfigurer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@AutoConfigureAfter(MyBatisConfig.class)
public class MybatisMapperScannerConfig {
    
    private static final Logger LOG = LoggerFactory.getLogger(MybatisMapperScannerConfig.class);
    
    /**
     * 通用mapper插件,支持通用的增删改查
     */
    @Bean
    public static MapperScannerConfigurer mapperScannerConfigurer() {
        LOG.info("********************** mapperScannerConfigurer *************************");
        MapperScannerConfigurer scannerConfigurer = new MapperScannerConfigurer();
        scannerConfigurer.setBasePackage("com.tssup.fesco.sales.*.persistent.mapper");
        
        scannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
        Properties props = new Properties();
        props.setProperty("mappers", "com.tssup.fesco.common.config.common.CommonMapper");
        props.setProperty("IDENTITY", "MYSQL");
        props.setProperty("notEmpty", "true");
        scannerConfigurer.setProperties(props);
        return scannerConfigurer;
    }
    
}
